#ifdef WX_PRECOMP
#include "../wx_pch.h"
#else
#include <wx/wx.h>
#endif //WX_PRECOMP

#include "about_dialog.h"

namespace
{
  wxString GetWxLibraryVersion()
  {
    // Retrieve library version info
    wxString result(wxVERSION_STRING);
    result << wxT(" (");
    #if defined(__WXMSW__)
    result << wxT("Windows");
    #elif defined(__WXMAC__)
    result << wxT("Mac");
    #elif defined(__UNIX__)
    result << wxT("Linux");
    #endif

    #if wxUSE_UNICODE
    result << wxT("; Unicode build");
    #else
    result << wxT("; ANSI build");
    #endif // wxUSE_UNICODE
    result << wxT(")");
    return result;
  }
}

BEGIN_EVENT_TABLE(AboutDialog, wxDialog)
  EVT_BUTTON( ID_ABOUT_WXBUTTONOK, AboutDialog::OnBoutonOK)
END_EVENT_TABLE()

//----------------------------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------------------------
AboutDialog::AboutDialog(wxWindowID id)
  : wxDialog(NULL, id, _("About"), wxDefaultPosition, wxSize(300, 425), wxDEFAULT_DIALOG_STYLE)
{
    //Your product is registered?
    bIsRegistered = true;

    //Load white bg
    wxBitmap emptyBackgroundBitmap(wxT("test.gif"), wxBITMAP_TYPE_GIF);
    new wxStaticBitmap(this, -1, emptyBackgroundBitmap, wxPoint(0, 138));

    //Load bg picture
    wxBitmap backgroundImage(wxT("6621467.gif"), wxBITMAP_TYPE_GIF);
    new wxStaticBitmap(this, -1, backgroundImage, wxPoint(0, 0));

    //Write the application name
    wxStaticText *myAppName = new wxStaticText(this, -1, wxT("wxDCDesigner"), wxPoint(12,150), wxSize(200,40), 0 );
    myAppName->SetFont(wxFont(28, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxT("Arial")));
    myAppName->SetBackgroundColour( wxT("WHITE") );
    myAppName->SetForegroundColour( wxColour( 220, 0, 0 ) );

    //Write the app version
    wxStaticText *myAppVersion = new wxStaticText(this, -1, wxT("1.0"), wxPoint(15, myAppName->GetPosition().y + 35), wxSize(200, 40), 0);
    myAppVersion->SetFont(wxFont(8, wxSWISS, wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL, false, wxT("Arial")));
    myAppVersion->SetBackgroundColour( wxT("WHITE") );
    myAppVersion->SetForegroundColour( wxColour( 120, 120, 120 ) );

    //Write text about copyrights... or anything you want
    wxStaticText *myAppCopyright = new wxStaticText(this,
                -1,
                wxString() + wxT("(c) 2010 - Als_ copyright"),
                wxPoint(myAppVersion->GetPosition().x, myAppVersion->GetPosition().y + 40),
                wxSize(200,100),
                0,
                wxT("myAppCopyright"));
    myAppCopyright->SetFont(wxFont(8, wxSWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Arial")));
    myAppCopyright->Wrap((int)(this->GetSize().x-2*15));
    myAppCopyright->SetBackgroundColour( wxT("WHITE") );
    myAppCopyright->SetForegroundColour( wxColour( 0, 0, 0 ) );

    const wxLanguageInfo* info = wxLocale::GetLanguageInfo(wxLANGUAGE_DEFAULT);
    wxString description;
    description << wxGetOsDescription() << wxT("; ") << (info ? info->CanonicalName : wxString());

    //Write build info
    wxStaticText *myAppInfo = new wxStaticText(this, -1, description,
      wxPoint(myAppVersion->GetPosition().x, myAppCopyright->GetPosition().y + 125), wxSize(20, 100), 0);
    myAppInfo->SetFont(wxFont(8, wxSWISS, wxFONTSTYLE_NORMAL, wxNORMAL, false, wxT("Arial")));
    myAppInfo->SetBackgroundColour( wxT("WHITE") );
    myAppInfo->SetForegroundColour( wxColour( 0, 0, 0 ) );

    //<< GetWxLibraryVersion()

    //Static line
    wxStaticLine *myStaticLine = new wxStaticLine(this, -1, wxPoint(0,this->GetSize().y-78), wxSize(this->GetSize().x,2), wxLI_HORIZONTAL, wxT("staticLine"));

    //Button 'OK'
  wxButton *myButtonOK = new wxButton(this, ID_ABOUT_WXBUTTONOK, _("OK"), wxPoint(this->GetSize().x-70-15,this->GetSize().y-50-15), wxSize(70,23), 0, wxDefaultValidator, wxT("myBOK"));
  myButtonOK->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
}
//---------------------------------------------------------------------------------------------------------
void
AboutDialog::OnClose( wxCommandEvent& WXUNUSED(event) )
{
  Close(TRUE);
}

//---------------------------------------------------------------------------------------------------------
void
AboutDialog::OnBoutonOK( wxCommandEvent& WXUNUSED(event) )
{
  Close(TRUE);
}
